# ============================================================
# Carnal Realms - Law-Aware Councilor and Clergy Recruitment
#
# CK2 Modding Bible controls used here:
# - create_random_diplomat / soldier / steward / intriguer / priest
# - create_character-style female = integer percentages
# - new_character scope
# - give_job_title
# - top_liege so the crown law governs rulers throughout the realm
#
# Councilor Gender controls:
#   Chancellor, Marshal, Steward, Spymaster
#
# Ordination Gender controls:
#   Court Chaplain
#
# Existing councilors are never removed when a law changes.
# A recruitment decision appears only when that council seat is vacant.
# ============================================================

decisions = {

	cr_recruit_chancellor = {
		only_playable = yes
		ai_check_interval = 3

		potential = {
			top_liege = {
				OR = {
					has_law = cr_councilor_gender_law_0
					has_law = cr_councilor_gender_law_1
					has_law = cr_councilor_gender_law_2
					has_law = cr_councilor_gender_law_3
					has_law = cr_councilor_gender_law_4
				}
			}

			NOT = {
				job_chancellor = { always = yes }
			}
		}

		allow = {
			prisoner = no
			is_incapable = no
			is_inaccessible_trigger = no
		}

		effect = {
			custom_tooltip = { text = cr_recruit_chancellor_effect_tt }
			hidden_tooltip = {
			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_0 }
				}
				create_random_diplomat = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = no
				}
				new_character = {
					give_job_title = job_chancellor
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_1 }
				}
				create_random_diplomat = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 25
				}
				new_character = {
					give_job_title = job_chancellor
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_2 }
				}
				create_random_diplomat = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 50
				}
				new_character = {
					give_job_title = job_chancellor
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_3 }
				}
				create_random_diplomat = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 75
				}
				new_character = {
					give_job_title = job_chancellor
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_4 }
				}
				create_random_diplomat = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = yes
				}
				new_character = {
					give_job_title = job_chancellor
				}
			}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
		}
	}

	cr_recruit_marshal = {
		only_playable = yes
		ai_check_interval = 3

		potential = {
			top_liege = {
				OR = {
					has_law = cr_councilor_gender_law_0
					has_law = cr_councilor_gender_law_1
					has_law = cr_councilor_gender_law_2
					has_law = cr_councilor_gender_law_3
					has_law = cr_councilor_gender_law_4
				}
			}

			NOT = {
				job_marshal = { always = yes }
			}
		}

		allow = {
			prisoner = no
			is_incapable = no
			is_inaccessible_trigger = no
		}

		effect = {
			custom_tooltip = { text = cr_recruit_marshal_effect_tt }
			hidden_tooltip = {
			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_0 }
				}
				create_random_soldier = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = no
				}
				new_character = {
					give_job_title = job_marshal
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_1 }
				}
				create_random_soldier = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 25
				}
				new_character = {
					give_job_title = job_marshal
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_2 }
				}
				create_random_soldier = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 50
				}
				new_character = {
					give_job_title = job_marshal
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_3 }
				}
				create_random_soldier = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 75
				}
				new_character = {
					give_job_title = job_marshal
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_4 }
				}
				create_random_soldier = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = yes
				}
				new_character = {
					give_job_title = job_marshal
				}
			}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
		}
	}

	cr_recruit_steward = {
		only_playable = yes
		ai_check_interval = 3

		potential = {
			top_liege = {
				OR = {
					has_law = cr_councilor_gender_law_0
					has_law = cr_councilor_gender_law_1
					has_law = cr_councilor_gender_law_2
					has_law = cr_councilor_gender_law_3
					has_law = cr_councilor_gender_law_4
				}
			}

			NOT = {
				job_treasurer = { always = yes }
			}
		}

		allow = {
			prisoner = no
			is_incapable = no
			is_inaccessible_trigger = no
		}

		effect = {
			custom_tooltip = { text = cr_recruit_steward_effect_tt }
			hidden_tooltip = {
			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_0 }
				}
				create_random_steward = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = no
				}
				new_character = {
					give_job_title = job_treasurer
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_1 }
				}
				create_random_steward = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 25
				}
				new_character = {
					give_job_title = job_treasurer
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_2 }
				}
				create_random_steward = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 50
				}
				new_character = {
					give_job_title = job_treasurer
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_3 }
				}
				create_random_steward = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 75
				}
				new_character = {
					give_job_title = job_treasurer
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_4 }
				}
				create_random_steward = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = yes
				}
				new_character = {
					give_job_title = job_treasurer
				}
			}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
		}
	}

	cr_recruit_spymaster = {
		only_playable = yes
		ai_check_interval = 3

		potential = {
			top_liege = {
				OR = {
					has_law = cr_councilor_gender_law_0
					has_law = cr_councilor_gender_law_1
					has_law = cr_councilor_gender_law_2
					has_law = cr_councilor_gender_law_3
					has_law = cr_councilor_gender_law_4
				}
			}

			NOT = {
				job_spymaster = { always = yes }
			}
		}

		allow = {
			prisoner = no
			is_incapable = no
			is_inaccessible_trigger = no
		}

		effect = {
			custom_tooltip = { text = cr_recruit_spymaster_effect_tt }
			hidden_tooltip = {
			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_0 }
				}
				create_random_intriguer = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = no
				}
				new_character = {
					give_job_title = job_spymaster
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_1 }
				}
				create_random_intriguer = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 25
				}
				new_character = {
					give_job_title = job_spymaster
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_2 }
				}
				create_random_intriguer = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 50
				}
				new_character = {
					give_job_title = job_spymaster
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_3 }
				}
				create_random_intriguer = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 75
				}
				new_character = {
					give_job_title = job_spymaster
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_councilor_gender_law_4 }
				}
				create_random_intriguer = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = yes
				}
				new_character = {
					give_job_title = job_spymaster
				}
			}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
		}
	}

	cr_recruit_chaplain = {
		only_playable = yes
		ai_check_interval = 3

		potential = {
			top_liege = {
				OR = {
					has_law = cr_ordination_law_0
					has_law = cr_ordination_law_1
					has_law = cr_ordination_law_2
					has_law = cr_ordination_law_3
					has_law = cr_ordination_law_4
				}
			}

			NOT = {
				job_spiritual = { always = yes }
			}
		}

		allow = {
			prisoner = no
			is_incapable = no
			is_inaccessible_trigger = no
		}

		effect = {
			custom_tooltip = { text = cr_recruit_chaplain_effect_tt }
			hidden_tooltip = {
			if = {
				limit = {
					top_liege = { has_law = cr_ordination_law_0 }
				}
				create_random_priest = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = no
				}
				new_character = {
					give_job_title = job_spiritual
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_ordination_law_1 }
				}
				create_random_priest = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 25
				}
				new_character = {
					give_job_title = job_spiritual
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_ordination_law_2 }
				}
				create_random_priest = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 50
				}
				new_character = {
					give_job_title = job_spiritual
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_ordination_law_3 }
				}
				create_random_priest = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = 75
				}
				new_character = {
					give_job_title = job_spiritual
				}
			}

			if = {
				limit = {
					top_liege = { has_law = cr_ordination_law_4 }
				}
				create_random_priest = {
					age = 30
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = yes
				}
				new_character = {
					give_job_title = job_spiritual
				}
			}
			}
		}

		revoke_allowed = {
			always = no
		}

		ai_will_do = {
			factor = 1
		}
	}

}
